﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 本地持久化数据
/// </summary>
public class UserData
{
    public bool isFirstGame = true;// 是否第一次游戏（只用于第一次玩游戏，即使重置数据也不再是第一次）    
    public bool isSilent;// 音乐开关
    public int diamondCount;// 钻石数量
    public bool[] skinUnlockState = {true, false, false, false};// 皮肤解锁状态
    public int[] skinUnlockDiamond = {0, 100, 200, 400};// 解锁皮肤花费的钻石
    public int selectSkin;// 当前选择皮肤
    public List<int> bestScore = new List<int>();// 最高分

    /// <summary>
    /// 重置玩家数据（清零）
    /// </summary>
    public void ResetUserData()
    {
        //isSilent = false;        
        diamondCount = 100;
        for (int i = 0; i < skinUnlockState.Length; i++)
        {
            if (i == 0)
            {
                skinUnlockState[i] = true;
            }
            else
            {
                skinUnlockState[i] = false;
            }
        }
        for (int i = 0; i < skinUnlockDiamond.Length; i++)
        {
            skinUnlockDiamond[i] = i * 100;
        }
        selectSkin = 0;        
        if (bestScore.Count < 4)
        {
            for (int i = 0; i < 4; i++)
            {
                bestScore.Add(0);
            }
        }
        else
        {
            for (int i = 0; i < bestScore.Count; i++)
            {
                bestScore[i] = 0;
            }
        }
    }


    /// <summary>
    /// 存储前进行数据处理
    /// </summary>
    /// <returns></returns>
    public UserData UpdateForSave()
    {
        return this;
    }
    /// <summary>
    /// 读取数据后进行预处理
    /// </summary>
    public void UpdateAfterRead()
    {
        
    }
}
